
	******************************************************************
	**
	**
	**		NAME:		GUY GROSSMAN, YOTAM MARGALIT, TAMAR MITTS
	**		DATE: 		December 15, 2021
	**		PROJECT: 	Israel Hayom
	**		DETAILS: 	This code generates figure SI-10
	**		Version: 	Stata MP 16
	**
	******************************************************************
	
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**

*set scheme plotplainblind, permanently
clear
version 16
set scheme plotplain
set more off

capture cd "~/dropbox/Israeli Newspapers Study/JOP_REPLICATION/Dataverse submission"

* bring in dataset

use "Data/yeshuvlong_final.dta"

* additional cleaning
	
replace israelhayom_percent_e=0 if israelhayom_percent_e==. & year<2007
replace israelhayom_percent=0 if israelhayom_percent==. & year<2007
replace israelhayom_percent_cumulative=0 if israelhayom_percent_cumulativ==. & year<2007

drop if area_num >25

keep if BIG_rightbloc!=.
tabulate year, gen(YEAR)

* gen a running number for election years 	
egen yr = group(year)
move yr year

gen lpop= log(potential)
gen ltd = log(travel_dist)

* generate turnout var
gen turnout = voters/potential
replace turnout = 1 if turnout>1
replace turnout = turnout*100
tab year, summ(turnout)

* population share by age group
gen pop_share1829 = pop_M_18_29 / pop_total 
gen pop_share3049 = pop_M_30_49 /pop_total
gen pop_share5065 = pop_M_50_65 /pop_total
gen pop_share66 = pop_M_66 / pop_total
gen pop_adult = pop_M_18_29 + pop_M_30_49 + pop_M_50_65 + pop_M_66
 
 foreach var in pop_share1829 pop_share3049 pop_share5065 pop_share66{
	replace `var'=0 if `var'<0
 }

tabstat ltd lpop age_median_08 matriccert_pcnt_08 europe_pcnt_08 asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66, by(yr)

corr ltd lpop age_median_08 potential matriccert_pcnt_08 europe_pcnt_08  asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 if yr==4

* generate otherpapers var for attentativeness measure
egen otherpapers=rowtotal(maariv_percent haaretz_percent globes_percent marker_percent calcalist_percent israelpost_percent makorrishon_percent) if year==2006
	bysort area_num: egen otherpapers2006=max(otherpapers)
	drop otherpapers
	
* rename parties	
ren Pisrael_beitenu Pib
ren BIG_rightbloc BRB
ren israelhayom_percent_electionyear IHE

* rename instruments
ren secular_max IVsm
ren secular_max07H1 IVsm07H1
ren sec_max06h2_07H1 IVsm06h2_07H1

tabstat IVsm IVsm07H1 IVsm06h2_07H1,  by(year)
corr IVsm IVsm07H1 IVsm06h2_07H1
drop IVsm

bysort area_num: egen IVsm=mean(IVsm07H1)
bysort area_num: egen IVsmp=mean(IVsm06h2_07H1)
tabstat IVsm IVsmp, by(year)
drop IVsm07H1 IVsm06h2_07H1

* generate variable of base level of support for right bloc and Likud
foreach var in BRB {
	bysort uniqueid: egen `var'0 = mean(`var') if yr<5
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	drop `var'0
	}

* use LERI score to calculate mean ideology support at baseline 
table year uniqueid if uniqueid<6, c(mean leri_score )	
foreach var in leri_AVscore leri_score{
	bysort uniqueid: egen `var'0 = mean(`var') if yr<5
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	drop `var'0
	}
		
xtset uniqueid yr
sort uniqueid yr	
estimates drop _all


*******************************************
* Parallel trends in 2015
******************************************* 

gen IH15 = IHE if year==2015
bysort area_num: egen IH2015=mean(IH15)
drop IH15

forvalues i = 1(1)7 { 
	bootstrap, reps(250) seed(321`i') cl(area_num) idcl(new_area_num) group(uniqueid) force : reg BRB IH2015 if yr==`i' [aw=potential], cl(area_num) 
	capture est sto parallel`i'
	tempfile m`i'
	margins , dydx(IH2015) level(90) post
	parmest, label bmat(r(b)) vmat(r(V)) saving(`m`i'') 	
	}
	
preserve 
use `m1', clear
	append using `m2'
	append using `m3'
	append using `m4'
	append using `m5'	
	append using `m6'
	append using `m7'
gen yr = _n
lab define yr 1 "1996" 2 "1999" 3 "2003" 4 "2006" 5 "2009" 6 "2013" 7 "2015", modify
lab value yr yr
tab yr 	

eclplot estimate min95 max95 yr, supby(parm, spaceby(0.15)) ///
		rplottype(rspike) ///
		ciopts(lc(black)) ///
		estopts1(col(ebg) msiz(vlarge) m(o)) ///
		estopts2(col(gs6) msiz(vlarge) m(t)) ///
		title("Parallel trends") xlabel(1 "1996" 2 "1999" 3 "2003" 4 "2006" 5 "2009" 6 "2013" 7 "2015")  ///
		legend(off) ///
		xline(4.33, lp(solid) lw(medthin) lc(red)) ytitle("IH2015 estimate") xtitle("Election year")
	graph export "figures/Fig_SI-10.pdf", replace
restore	

